# 1.编写一个装饰器，用于记录函数的调用日志，包括调用函数名、时间和参数，调用结束后输出调用函数名和时间
import time


def fun_log(fun):
    def inner(*args, **kwargs):
        record_dict_log = {"函数名": fun.__name__, "时间": time.strftime("%Y-%m-%d %H:%M:%S")}
        if args:
            record_dict_log["参数args"] = args
        if kwargs:
            record_dict_log["参数kwargs"] = kwargs
        record_log.append(record_dict_log)

        time1 = time.time()
        fun(*args, **kwargs)
        time2 = time.time()

        print(f"函数名:{fun.__name__},运行时间:{time2 - time1}")

    return inner


@fun_log
def circulation1():
    print("circulation1:", end="")
    for i in range(0, 2):
        print(i, end=" ")
        time.sleep(0.3)
    print()


@fun_log
def circulation2(list1):
    print("circulation2:", end="")
    for item in list1:
        print(item, end=" ")
        time.sleep(0.1)
    print()


if __name__ == "__main__":
    record_log = []

    circulation1()
    print()

    list1 = ["q", "g", "a", "h", "k", "p", "a", "y", "j", "m"]
    circulation2(list1)
    print()

    for item in record_log:
        print(item)